package com.yztc.yidoutang.fragment.jingxuan_fragment;

import com.yztc.yidoutang.bean.JingXuanBean;
import com.yztc.yidoutang.http.HttpHelper;
import com.yztc.yidoutang.http.JingXuanService;

import retrofit2.Retrofit;
import rx.Observable;
import rx.Observer;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by My on 2016/10/17.
 */

public class JingXuanModel implements JingXuanContract.Model {

    @Override
    public void getJingXuanData(final JingXuanContract.OnLoadJingXuanListener loadJingXuanListener) {
        Retrofit retrofit= HttpHelper.getInstance().getRetrofit();
        Observable<JingXuanBean> observable=retrofit.create(JingXuanService.class).getJingXuanList();
        observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<JingXuanBean>() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onNext(JingXuanBean jingXuanBean) {
                loadJingXuanListener.onSuccess(jingXuanBean);
            }
        });
    }
}
